<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>判断大小并排序</title>
</head>

<body>
    <script>
        // 定义一个参数fun，定义形参a，b，c
        function fun(a, b, c) {
            // var a = 50;
            // var b = 30;
            // var c = 40;

            
            var change = 0;     // 引入变量储存二者的较大值
            if (a > b) {
                change = a;
                a = b;
                b = change;
                // console.log(a,b,change)
            }

            if (a > c) {
                change = a;
                a = c;
                c = change;
                // console.log(change)
            }
            
            if (b > c) {
                change = b;
                // console.log(b)
                b = c;
                c = change;
            }         
            console.log(`从小到大的顺序是${a},${b},${c}`)
        }
        // 调用并传参
       fun(50,30,40);
       fun(30,20,50);
       fun(5.4,5.3,5.2)
    </script>
</body>

</html>